import { _decorator, Collider2D, Component, Contact2DType, find, IPhysics2DContact, Node, v2 } from 'cc';
import { MainLlogic } from './MainLlogic';
const { ccclass, property } = _decorator;

@ccclass('Coin')
export class Coin extends Component {
    start() {

        this.node.getComponent(Collider2D).on(Contact2DType.BEGIN_CONTACT,this.onBeginContact,this)
    }

    onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null){
        if(otherCollider.group == 2){
            find('Canvas/MainLogic').getComponent(MainLlogic).recon = true
            this.node.destroy()
        }
        
    }

    update(deltaTime: number) {
        
    }
}


